package com.yanqu.road.server.cmd.activity.hsisland.cross;

import com.yanqu.road.entity.activity.args.ActivityValueParamArgs;
import com.yanqu.road.entity.enums.eGamePlayerEventType;
import com.yanqu.road.message.YanQuMessage;
import com.yanqu.road.pb.activity.HsIslandProto;
import com.yanqu.road.server.cmd.base.AbstractCommand;
import com.yanqu.road.server.command.Cmd;
import com.yanqu.road.server.gameplayer.GamePlayer;
import com.yanqu.road.server.gameplayer.module.activity.fund.ActivityFundModule;
import com.yanqu.road.server.protocol.Protocol;

@Cmd(code = Protocol.S_HS_ISLAND_CONDITION_CHANGE_FROM_CROSS, desc = "海神岛-跨服返回-通知区服condition分变更")
public class HsIslandConditionChangeFromCrossCmd extends AbstractCommand {

    @Override
    public boolean parseData(YanQuMessage packet) throws Exception {
        return true;
    }

    @Override
    public void execute(GamePlayer player, YanQuMessage packet) throws Exception {
        HsIslandProto.HsIslandConditionChangeFromCrossMsg reqMsg = HsIslandProto.HsIslandConditionChangeFromCrossMsg.parseFrom(packet.getBytes());
        if (player != null) {
            //判断是否是基金
            if (reqMsg.getConditionType() == eGamePlayerEventType.CommonActivityFundProgress.getValue()) {
                player.getModule(ActivityFundModule.class).updateProgress(reqMsg.getActivityId(), reqMsg.getValue());
            } else {
                //condition变更
                ActivityValueParamArgs args = new ActivityValueParamArgs(reqMsg.getActivityId(), reqMsg.getValue(), reqMsg.getParam());
                player.notifyListener(reqMsg.getConditionType(), args);
            }
        }
    }

    @Override
    public void sendData(GamePlayer player) {}
}
